package pers.bc.utils.yonyou;

import java.io.File;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import pers.bc.utils.file.FileUtilbc;
import pers.bc.utils.pub.LoggerUtil;
import pers.bc.utils.pub.PropertiesUtil;
import pers.bc.utils.pub.PubEnvUtil;
import pers.bc.utils.pub.StringUtil;

public class YonLogUtil
{
    private static final Logger logger = LoggerFactory.getLogger(YonLogUtil.class);
    
    public static String moduleName = "yonyoulogs";
    public static String folderName = "Mylogs" + File.separator + "debugLogs";
    
    public static void debug(Object objMsg, Object agrs)
    {
        if (isPrintLog()) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg), StringUtil.toString(agrs));
        logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
    }
     
    public static void debug(Object objMsg)
    {
        if (isPrintLog()) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg));
        logger.error(StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(objMsg));
    }
    
    public static void debug(Boolean isPrintLog, Object objMsg)
    {
        if (isPrintLog) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg));
        logger.error(StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(objMsg));
    }
    
    public static void debug(Boolean isPrintLog, Object objMsg, Object agrs)
    {
        if (isPrintLog) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg), StringUtil.toString(agrs));
        logger.error(StringUtil.toString(objMsg) + "+++++++++：" + StringUtil.toString(agrs));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(objMsg) + "+++++++++：" + StringUtil.toString(agrs));
    }
    
    /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
    public static void debug(String folderName, Object objMsg, Object agrs)
    {
        if (isPrintLog()) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg), StringUtil.toString(agrs));
        logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
    }
    
    public static void debug(String folderName, Object objMsg)
    {
        if (isPrintLog()) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg));
        logger.error(StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(objMsg));
    }
    
    public static void debug(Boolean isPrintLog, String folderName, Object objMsg, Object agrs)
    {
        if (isPrintLog) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg), StringUtil.toString(agrs));
        logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(agrs) + "+++++++++：" + StringUtil.toString(objMsg));
    }
    
    public static void debug(Boolean isPrintLog, String folderName, Object objMsg)
    {
        if (isPrintLog) LoggerUtil.getInstance(folderName).debug(StringUtil.toString(objMsg));
        logger.error(StringUtil.toString(objMsg));
       //  nc.bs.logging.Logger.init(moduleName);
       //  nc.bs.logging.Logger.error(StringUtil.toString(objMsg));
    }
    
    static String printlog = "";
    
    static Boolean isPrintLog()
    {
        try
        {
            if (PubEnvUtil.isEmpty(printlog))
            {
                String properPatch = FileUtilbc.getWorkServerPath() + File.separator + "resources" //
                    + File.separator + "server.properties";
                Map<String, String> map = PropertiesUtil.getAllProperties(properPatch);
                printlog = StringUtil.valueOfEmpty(map.get("printlog"));
            }
            if (PubEnvUtil.equals("y", printlog) || PubEnvUtil.equals("Y", printlog)//
                || PubEnvUtil.equals("true", printlog) //
                || PubEnvUtil.equals("TRUE", printlog)) return Boolean.TRUE;
        }
        catch (Exception e)
        {
            return Boolean.FALSE;
        }
        
        return Boolean.FALSE;
    }
    
}
